#pragma hdrstop
#include "TLed.h"
#pragma package(smart_init)

__fastcall TLed::TLed(TComponent* owner){
	TOWBoolChangeEvent event = &(this->berechne);
	TOWPinDispatchEvent dispatchEvent = &(this->pinDispatched);
	//* Initialisierung des inputpins
	this->inputPin = new TOWBoolSinkPin((TComponent*) owner, event, dispatchEvent, NULL);


}

void __fastcall TLed::setGuiComponent(TBauelementGUI* guiElement){
	this->guiElement = guiElement;
}


void __fastcall TLed::berechne(TOWPin* Sender, bool value, bool onConnect){
		((TBauelementGUI*)this->guiElement)->changeLEDstatus(value);
}

bool __fastcall TLed::connect(Pin pin, TOWBasicPin* pinToConnectTo){
	return this->inputPin->Connect(pinToConnectTo);
}

void __fastcall TLed::disconnect(Pin pin){
	this->inputPin->Disconnect();

}

TOWBasicPin* __fastcall TLed::getPin(Pin pin){
	TOWBasicPin* ret;

	switch (pin) {
		case INPUT_PIN_OL: //InputPin 1
			ret = this->inputPin;
			break;
		default:
			ret = NULL;
	}

	return (ret);
}

TOWNotifyResult __fastcall TLed::pinDispatched(PDataTypeID dataTypeID, _di_IOWNotifyOperation operation, TOWNotifyState state, bool& x){

	return TOWNotifyResult();

}

__fastcall TLed::~TLed(){
	this->inputPin->Free();
}


